package net.lab1024.sa.admin.module.business.sp.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.sp.domain.SpVO;
import net.lab1024.sa.admin.module.business.sp.domain.form.SpAddForm;
import net.lab1024.sa.admin.module.business.sp.domain.form.SpQueryForm;
import net.lab1024.sa.admin.module.business.sp.domain.form.SpUpdateForm;
import net.lab1024.sa.admin.module.business.sp.service.SpService;
import net.lab1024.sa.base.common.controller.SupportBaseController;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.constant.SwaggerTagConst;
import net.lab1024.sa.base.module.support.config.domain.ConfigAddForm;
import net.lab1024.sa.base.module.support.config.domain.ConfigUpdateForm;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;

/**
 * 配置
 *
 * @Author 1024创新实验室-主任: 卓大
 * @Date 2022-03-14 20:46:27
 
 
  * @Copyright  cpedu
 */
@Tag(name = SwaggerTagConst.Support.CONFIG)
@RestController
public class SpController extends SupportBaseController {

    @Resource
    private SpService spService;

    @Operation(summary = "分页商品信息")
    @PostMapping("/sp/query")
    @SaCheckPermission("support:sp:query")
    public ResponseDTO<PageResult<SpVO>> querySpPage(@RequestBody @Valid SpQueryForm spqueryForm) {
        return spService.querySpPage(spqueryForm);
    }
//
    @Operation(summary = "添加商品信息  ")
    @PostMapping("/sp/add")
    @SaCheckPermission("support:sp:add")
    public ResponseDTO<String> addSp(@RequestBody @Valid SpAddForm spAddForm) {
        return spService.add(spAddForm);
    }

    @Operation(summary = "修改商品参数  ")
    @PostMapping("/sp/update")
//                 suppot:sp:update
//                 support:sp:update
    @SaCheckPermission("support:sp:update")
    public ResponseDTO<String> updateSp(@RequestBody @Valid SpUpdateForm updateForm) {
        return spService.updateSp(updateForm);
    }
    @Operation(summary = "删除商品信息  ")
    @PostMapping("/sp/delete")
    @SaCheckPermission("support:sp:delete")
    public ResponseDTO<String> deleteSp(@RequestBody @Valid SpUpdateForm updateForm) {
        return spService.deleteSp(updateForm);
    }

}
